package com.xy.biz.mc.configuration;

import com.auth0.jwt.algorithms.Algorithm;
import com.xy.tool.jwt.TokenParser;
import com.xy.tool.jwt.TokenParserImpl;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class JwtConfiguration {

    @Value("${xy.jwt.sk}")
    private String sk;
    //@Value("${spring.application.name}")
    private String issuer = "xy-biz-xd";

    @Bean
    public Algorithm getAlgorithm() {
        return Algorithm.HMAC512(sk);
    }

    @Bean
    public TokenParser tokenParser() {
        return new TokenParserImpl(getAlgorithm(), issuer);
    }

}
